package com.msb.consumer.interceptor;

import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;

/**
 * @author DreamAndLove
 * @date 2024/09/05 15:47
 * @description
 */
public class LoggingClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
        System.out.println("开始拦截请求。。。");
        System.out.println("URI: "+ httpRequest.getURI());
        ClientHttpResponse response = clientHttpRequestExecution.execute(httpRequest, bytes);
        System.out.println(response.getHeaders());
        return response;
    }
}
